package com.xushu.service;

import com.xushu.pojo.Customer;
import com.xushu.repositories.CustomerRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.concurrent.CountDownLatch;

/***
 * @Author 徐庶   QQ:1092002729
 * @Slogan 致敬大师，致敬未来的你
 */
@Service
public class CustomerServiceImple implements  CustomerService{

    @Autowired
    CustomerRepository repository;

    @Override
    @Async("asyncThreadPoolExecutor")
    public void saveAll(List<Customer> list, CountDownLatch countDownLatch) {
        try {
            repository.saveAll(list);
        }
        finally {
            countDownLatch.countDown();
        }
    }
    @Override
    public void saveAll(List<Customer> list) {
            repository.saveAll(list);
    }
}
